//
//  ResetPWDViewController.m
//  LANDSKY
//
//  Created by 3TI on 14-2-10.
//  Copyright (c) 2014年 qiaquan. All rights reserved.
//

#import "ResetPWDViewController.h"

#import "TaskWithForgetPWD.h"

@interface ResetPWDViewController ()<WYHttpTaskDelegate>

@property (nonatomic,strong)MBProgressHUD *mb;

@end

@implementation ResetPWDViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    self.email.layer.borderColor = [[UIColor darkGrayColor] colorWithAlphaComponent:.4].CGColor;
    self.email.layer.borderWidth = 1.0f;
    
}


#pragma mark UIButton Method


#pragma mark - http delegate -

-(void)requestCompleteWithObj:(WYHttpTask *)obj{
    
    [self.mb hide:YES afterDelay:0];
    [UIAlertView showAlertViewWithTitle:@"" withMessage:@"查看邮箱" withAction:^(NSInteger index) {
        if(index == 0){
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
}
-(void)requestFailWithMsg:(WYHttpTask *)obj{
    DLog(@"%@",obj.networkOp.url);

    self.mb.labelText = obj.rcvData[@"body"];
    [self.mb hide:YES afterDelay:.8];
}


#pragma mark Customer Method

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)on_btn_send:(id)sender {
    
    if(!self.email.text.length){
        [UIAlertView showAlertViewWithTitle:@"邮件不能为空"];
        return;
    }

    self.mb = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

    
    TaskWithForgetPWD *reg = [[TaskWithForgetPWD alloc] init];

    reg.email = self.email.text;

    reg.delegate = self;
    [reg start];
}
@end
